package org.example.spring_ioc.controller;

import org.example.spring_ioc.model.DbType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RequestMapping("/yml")
@RestController
public class ymlController {
    @Value("${mykey}")
    private String key;

    @Value("${server.port}")
    private Integer port;

    @Autowired    //@Value不能注入复杂的集合类型
    private DbType dbType;


    @RequestMapping("read")
    public String readYml(){
        return "读取yml配置文件: "+key;
    }

    @RequestMapping("read2")
    public String readYml2(){
        return "读取yml配置文件: "+port;
    }

    @RequestMapping("read3")
    public String readYml3(){
        return "读取yml配置文件: "+dbType;
    }

    @RequestMapping("read4")
    public String readYml4(){
        return "读取yml配置文件: "+dbType.getMap();
    }
}
